#pragma once

#include <vector>

namespace MCCommon
{

class CppHelper
{
public:
    
    /**
     * Safe delete a vector of pointers.
     * 
     */
    template< class T>
    static void SafeDel
    (
        std::vector< T* >& vp
    )
    {
        for( int i=0; i<(int)vp.size(); i++ )
        {
            if ( 0 != vp[i] )
            {
                delete vp[i];
                vp[i] = 0;
            }
        }
        vp.clear();
    }

    /**
     * Safe delete a pointer.
     * 
     */
    template< class T>
    static void SafeDel
    (
        T*& p
    )
    {        
        if ( 0 != p )
        {
            delete p;
            p = 0;
        }
    }

    /**
     * Change from ANSI to Unicode.
     * 
     */
    static wchar_t* Ansi2Unicode
    (
        const char* astr
    );

    /**
     * Change from Unicode to ANSI.
     * 
     */
    static char* Unicode2Ansi
    (
        const wchar_t* wstr
    );

    /**
     * Change form Unicode to UTF-8
     * 
     */
    static char* Unicode2UTF8
    (
        const wchar_t* wstr
    );
};

} // end of namespace MCCommon.